package com.markedquilt.controller;
/*
 * PackageName: com.markedquilt.my_session.controller
 * Author:   coke
 * Date:     Created in 2020/11/22 0:36
 * Description:
 * History:
 * <author>        <time>             <version>          <desc>
 * 作者姓名         修改时间            版本号              描述
 * coke           2020/11/22 0:36     1.0
 */

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * @author ZhangKe
 * @Description
 * @date 2020/11/22 0:36.
 */
@Controller
@RequestMapping("/user")
public class LoginController {

    @RequestMapping("/login")
    public String Login(String username,String password,HttpSession session){
        if ("admin".equals(username) && "admin".equals(password)){
            System.out.println("登陆成功");
            session.setAttribute("username",username);
            session.setAttribute("password",password);

            return "redirect:/resume/list";
        }
        else{
            System.out.println("账号密码错误");
            return "redirect:/user/failure";
        }
    }

    @RequestMapping("/failure")
    public String toLogin() {
        System.out.println("账号密码错误，请重新登录");
        return "/login.jsp";
    }
}
